<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="title"
  [loading]="isLoading()"
></ix-modal-header>

<mat-card>
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      <ix-fieldset>
        <ix-input
          formControlName="name"
          [label]="'Name' | translate"
          [required]="true"
        ></ix-input>

        <ix-chips
          formControlName="local_groups"
          [label]="'Local Groups' | translate"
          [autocompleteProvider]="localGroupsProvider"
          [allowNewEntries]="false"
        ></ix-chips>

        @if (isEnterprise()) {
          <ix-chips
            formControlName="ds_groups"
            [label]="'Directory Services Groups' | translate"
            [autocompleteProvider]="dsGroupsProvider"
            [allowNewEntries]="true"
          ></ix-chips>
        }

        <ix-select
          formControlName="roles"
          [label]="'Roles' | translate"
          [options]="rolesOptions$"
          [multiple]="true"
          [showSelectAll]="true"
          [hint]="helptext.minimalRolesTooltip | translate"
        ></ix-select>

        <ix-checkbox
          formControlName="web_shell"
          [label]="'Web Shell Access' | translate"
        ></ix-checkbox>
      </ix-fieldset>

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          type="submit"
          mat-button
          color="primary"
          ixTest="save"
          [disabled]="!form.valid || isLoading()"
        >
          {{ 'Save' | translate }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
